package services

import (
	"github.com/dchest/captcha"
	"micro-bbs/initialize"
)

type CaptchaInterfaceService interface {
	VerifyCaptcha(id string, value string) bool //效验验证码
}

//初始化对象函数
func NewCaptchaService() CaptchaInterfaceService {
	return &captchaService{
	}
}

type captchaService struct {
}

//获取用户信息
func (this *captchaService) VerifyCaptcha(id string, value string) bool{
	// checking whether captcha-id and captcha-value is matched
	if captcha.VerifyString(id, value) {
		initialize.IrisLog.Infof("[效验验证码]-[%s]", "ok")
		return true
	} else {
		initialize.IrisLog.Errorf("[效验验证码]-[%s]", "mismatch")
		return false
	}
}
